package com.zx.zxpicture.application.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zx.zxpicture.interfaces.dto.user.UserQueryRequest;
import com.zx.zxpicture.domain.user.entity.User;
import com.zx.zxpicture.interfaces.dto.user.UserRegisterRequest;
import com.zx.zxpicture.interfaces.vo.LoginUserVO;
import com.zx.zxpicture.interfaces.vo.UserVO;

import java.util.Collection;
import java.util.List;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;

/**
 * 用户应用服务层
 *
 * @author <a href="https://github.com/liyupi">程序员鱼皮</a>
 * @from <a href="https://yupi.icu">编程导航知识星球</a>
 */
public interface UserApplicationService{

    /**
     * 用户注册
     *
     * @param userRegisterRequest 用户注册请求
     * @return 新用户 id
     */
    long userRegister(UserRegisterRequest userRegisterRequest);

    /**
     * 用户登录
     *
     * @param userAccount  用户账户
     * @param userPassword 用户密码
     * @param request
     * @return 脱敏后的用户信息
     */
    LoginUserVO userLogin(String userAccount, String userPassword, HttpServletRequest request);

    /**
     * 添加用户
     * @param user
     * @return
     */
    long addUser(User user);


    /**
     * 获取当前登录用户
     *
     * @param request
     * @return
     */
    User getLoginUser(HttpServletRequest request);


    /**
     * 是否为管理员
     *
     * @param request
     * @return
     */
    boolean isAdmin(HttpServletRequest request);

    /**
     * 是否为管理员
     *
     * @param user
     * @return
     */
    boolean isAdmin(User user);

    /**
     * 用户注销
     *
     * @param request
     * @return
     */
    boolean userLogout(HttpServletRequest request);

    /**
     * 获取脱敏的已登录用户信息
     *
     * @return
     */
    LoginUserVO getLoginUserVO(User user);

    /**
     * 获取脱敏的用户信息
     *
     * @param user
     * @return
     */
    UserVO getUserVO(User user);

    /**
     * 获取脱敏的用户信息
     *
     * @param userList
     * @return
     */
    List<UserVO> getUserVO(List<User> userList);

    /**
     * 获取查询条件
     *
     * @param userQueryRequest
     * @return
     */
    QueryWrapper<User> getQueryWrapper(UserQueryRequest userQueryRequest);

    /**
     * 删除用户byId
     * @param id
     * @return
     */
    boolean removeById(Long id);

    /**
     * 更新用户信息
     * @param user
     * @return
     */
    boolean updateById(User user);

    /**
     * 查询用户
     * @param id
     * @return
     */
    User getById(long id);

    /**
     * 分页查询用户
     * @param page
     * @param queryWrapper
     * @return
     */
    Page<User> page(Page<User> page, QueryWrapper<User> queryWrapper);

    Collection<User> listByIds(Set<Long> userIds);
}
